package com.csy.user.service.impl;

import java.math.BigDecimal;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.csy.user.entity.CarPark;
import com.csy.user.mapper.CarParkMapper;
import com.csy.user.service.ICarParkService;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2025-02-27
 */
@Service
public class CarParkServiceImpl extends ServiceImpl<CarParkMapper, CarPark> implements ICarParkService {

    @Resource
    CarParkMapper carParkMapper;

    BigDecimal small = null;
    BigDecimal big = null;

    /**
     * 汽车到闸列表
     * @param carPark
     * @return
     */
    @Override
    public List<CarPark> select(CarPark carPark) {
        small = carPark.getSmall();
        big = carPark.getBig();

        if (small != null && big != null){
            getSmallBig(small,big);
        }
        carPark.setSmall(small);
        carPark.setBig(big);
        List<CarPark> list = carParkMapper.select(carPark);

        return list;
    }

    /**
     * 把小的数给s，大的数给b
     * @param s
     * @param b
     */
    public void getSmallBig(BigDecimal s,BigDecimal b){
        BigDecimal temp = null;
        int i = s.compareTo(b);
        if (i < 0){
            //s<b
        }else if (i == 0){
            //s==b
        }else {
            //s>b
            temp = big;
            big = small;
            small = temp;
        }
    }
}
